package com.santu.edu.supporter.biz.buildings.pojo.vo;

import com.santu.edu.supporter.biz.buildings.pojo.dto.BuildingsDTO;
import com.santu.edu.supporter.biz.buildings.pojo.enums.BuildingsType;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author luoyaoqi
 * @createTime 2024/3/1
 * @description
 */
@Data
@Accessors(chain = true)
public class BuildingsVO {

    /**
     * 学校id
     */
    private String schoolId;

    /**
     * 楼栋id
     */
    private String buildingsId;

    /**
     * 楼栋地址
     */
    private String buildingsName;

    /**
     * 楼栋类型
     */
    private Integer type;

    public static List<BuildingsVO> convert(List<BuildingsDTO> dtoList) {
        return dtoList.stream().map(BuildingsVO::createItem).collect(Collectors.toList());
    }

    public static BuildingsVO createItem(BuildingsDTO dto) {
        return new BuildingsVO()
                .setSchoolId(dto.getSchoolId())
                .setBuildingsId(dto.getBuildingsId())
                .setBuildingsName(dto.getBuildingsName())
                .setType(dto.getType().getCode());
    }
}
